/**
 * @team Samurai Pizza Cats
 * 1. Tom Doron
 * 2. Gal Rotem
 * 3. Dor Porat
 */

import poland.Calc;

import java.io.*;
import java.lang.* ;

class Main {
	public static void main(String[] args) {
		Calc c = new Calc();
		try{
			  FileInputStream fstream = new FileInputStream(args[0]);
			  DataInputStream in = new DataInputStream(fstream);
			  BufferedReader br = new BufferedReader(new InputStreamReader(in));
			  String strLine;
			  while ((strLine = br.readLine()) != null)   {
				  if(c.process(strLine)){
					System.out.println(strLine +	" : " + trimParanthesis(c.getTextualValue()) + " = " + c.getValue());
				  }
				  else {
					System.out.println(strLine +	" : invalid expression");
				  }
			  }
			  in.close();
	    }
		catch (Exception e) {
			  System.err.println("Error: " + e.getMessage());
		}
	}
	
	private static String trimParanthesis(String str) {
		if (str.charAt(0) == '('){
			return str.substring(1, str.length()-1);
		}
		return str;
		
	}
}

